package com.attms.controller;

import com.attms.domain.Absent;
import com.attms.service.IDManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.attms.controller.utils.R;

@RestController
@RequestMapping("/dmanager")
public class DManagerController {
    @Autowired
    private IDManagerService idManagerService;

    @GetMapping("/absentlist/{department}")
    public R getAbsentlist(@PathVariable(value = "department") Integer department) {
        return new R(true, idManagerService.getAbsentList(department));
    }
    @GetMapping("/absentlistnosolve/{department}")
    public R getAbsentlistNosolve(@PathVariable(value = "department") Integer department) {
        return new R(true, idManagerService.getAbsentListNosolve(department));
    }

    @PostMapping("/{isagree}")
    //部门经理处理请假
    public R solveLeave(@PathVariable("isagree")Integer isagree, @RequestBody Absent absent){
        return new R(true, idManagerService.solveLeave(isagree, absent));

    }

    // 部门经理生成个人请假记录(按照时间，默认为全时间段)
    @GetMapping("/personal")
    public R getPersonalAbsentList(@RequestBody Absent absent) {
        return new R(true, idManagerService.getPersonalAbsentList(absent));
    }

    // 部门经理生成本部分请假记录(按照时间，默认为全时间段)
    @PostMapping("/all/{department}")
    public R getAllAbsentList(@PathVariable(value = "department") Integer department, @RequestBody Absent absent) {

        return new R(true, idManagerService.getAllAbsentList(department, absent));
    }
}
